package com.ysd.lis.controller.sys;

import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.request.*;
import com.ysd.lis.service.SysUserAuthdetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: server_lis
 * @author: liuQi
 * @create: 2023-10-31 09:42
 */
@Api(tags = "获取用户详细权限数据")
@RestController
@RequestMapping("/api/user/sysUserAuthDetail")
public class SysUserAuthdetailController {

    @Autowired
    private SysUserAuthdetailService sysUserAuthdetailService;

    @ApiOperation("根据角色ids查询用户详细数据")
    @PostMapping("/getSysUserAuthdetailsByRoleIds")
    public Result getSysUserAuthdetailsByRoleIds(@RequestBody HandelUserAuthParam handelUserAuthParam) {
        return sysUserAuthdetailService.getSysUserAuthdetailsByRoleIds(handelUserAuthParam);
    }

    @ApiOperation("根据角色id查询用户列表数据")
    @PostMapping("/getUserListByRoleId")
    public Result getUserListByRoleId(@RequestBody AuthFindUserListParam authFindUserListParam) {
        return sysUserAuthdetailService.getUserListByRoleId(authFindUserListParam);
    }

    @ApiOperation("根据用户id查询用户权限数据")
    @GetMapping("/getLoginUserAuthMapByUserId")
    public Result getLoginUserAuthMapByUserId(@RequestParam String userId) {
        return sysUserAuthdetailService.getLoginUserAuthMapByUserId(userId);
    }

    @ApiOperation("根据角色id和角色ids处理用户详情数据")
    @PostMapping("/handleUserAuthDetails")
    public Result handleUserAuthDetails(@RequestBody HandelUserAuthParam handelUserAuthParam) {
        return sysUserAuthdetailService.handleUserAuthDetails(handelUserAuthParam);
    }

    @ApiOperation("根据详情id删除详情数据")
    @PostMapping("/deleteUserAuthById")
    @LogDetail(requestParam ="deleteUserAuthById",operationType = OperationType.DELETE, module = "用户授权",content = "删除了【username】的【title】权限", businessName = "username")
    public Result handleUserAuthDetails(@RequestBody UserAuthDeleteParam userAuthDeleteParam) {
        return sysUserAuthdetailService.deleteUserAuthById(userAuthDeleteParam.getId());
    }

    @ApiOperation("根据用户id查询角色差集信息")
    @PostMapping("/getDifferenceSetRoles")
    public Result getDifferenceSetRoles(@RequestBody HandelUserAuthParam handelUserAuthParam) {
        return sysUserAuthdetailService.getDifferenceSetRoles(handelUserAuthParam);
    }

    @ApiOperation("根添加角色差集信息")
    @PutMapping("/addUserAuthDetails")
    @LogDetail(requestParam ="addUserAuthDetails",operationType = OperationType.INSERT, module = "用户授权",content = "增加了【username】的【roleName】角色权限", businessName = "username")
    public Result addUserAuthDetails(@RequestBody UserAuthAddParam userAuthAddParam) {
        return sysUserAuthdetailService.addUserAuthDetails(userAuthAddParam);
    }

    @ApiOperation("根据员工信息导入详细数据表")
    @PostMapping("/importSysUserAuthDetailsByEmployee")
    @LogDetail(requestParam ="importSysUserAuthDetailsByEmployee",operationType = OperationType.OTHER, module = "用户管理",content = "导入【roleId】的权限", businessName = "roleId")
    public Result importSysUserAuthDetailsByEmployee(@RequestBody ImportUserAddParam importUserAddParam) {
        return sysUserAuthdetailService.importSysUserAuthDetailsByEmployee(importUserAddParam.getRoleId(), importUserAddParam.getEmployeeIds());
    }


}
